﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>大范围的多选</title>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../../Comm/Gener.js" type="text/javascript"></script>
   <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />
    <base target="_self" />
    <script type="text/javascript">
        //页面启动函数.
        $(function () {

            //组织主键.
            var mypk = "MultipleChoiceSmall_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            var i = en.RetrieveFromDBSources();
            if (i == 0)
                $("#Btn_Delete").attr("disabled", true);
            else
                $("#Btn_Delete").removeAttr("disabled");

            //设置文本框选择的值.
            $("input[name='RB']:checked").val(en.DoWay);

            //按照文本计算.
            $("#TB_Doc").val(en.Tag1);

            //绑定枚举.
            var enums = new Entities("BP.Sys.SysEnumMains");
            enums.RetrieveAll();

            GenerBindDDL("DDL_Enums", enums, "No","Name", en.Tag2);

            //绑定外键.
            var tables = new Entities("BP.Sys.SFTables");
            tables.RetrieveAll();
            GenerBindDDL("DDL_SFTables", tables, "No", "Name", en.Tag3);

            //绑定SQL
            $("#TB_SQL").val(en.Tag4);

        });

        //执行保存
        function Save() {

            //组织主键.
            var mypk = "MultipleChoiceSmall_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.RetrieveFromDBSources();

            en.FK_MapData = GetQueryString("FK_MapData");
            en.AttrOfOper = GetQueryString("KeyOfEn");
            en.ExtType = "MultipleChoiceSmall";
            en.MyPK = mypk;

            var checkVal = $("input[name='RB']:checked").val();
            en.DoWay = checkVal;

            en.Tag1 = $("#TB_Docs").val();

            en.Tag2 = $("#DDL_Enums").val();

            en.Tag3 = $("#DDL_SFTables").val();

            en.Tag4 = $("#TB_SQL").val();

            if (en.Update() == 0)
                en.Insert();

            window.location.href = "MultipleChoiceSmall.htm?FK_MapData=" + GetQueryString("FK_MapData") + "&KeyOfEn=" + GetQueryString("KeyOfEn") + "&M=" + Math.random();
            return;
        }

        //删除.
        function Delete() {

            if (window.confirm('您确定要删除吗？') == false)
                return;

            var mypk = "MultipleChoiceSmall_" + GetQueryString("FK_MapData") + "_" + GetQueryString("KeyOfEn");
            var en = new Entity("BP.Sys.MapExt");
            en.MyPK = mypk;
            en.RetrieveFromDBSources();
            en.Delete();

            var url = "MultipleChoiceSmall.htm?FK_MapData=" + GetQueryString("FK_MapData") + "&KeyOfEn=" + GetQueryString("KeyOfEn") + "&M=" + Math.random();
            window.location.href = url;
        }
    </script>
</head>
<body >
<form id="cc">



<fieldset>
<legend><input type="radio" value="0" id="RB_0"  name="RB" /><label for="RB_0" >无，不设置</label> </legend>
 </fieldset>

 
<fieldset>
<legend><input type="radio" value="1" id="RB_1"  name="RB" /><label for="RB_1" >按文本输入的值</label> </legend>
<textarea  rows="3" id="TB_Docs" name="TB_Docs" ></textarea>
 </fieldset>

 
<fieldset>
<legend><input type="radio" value="2" id="RB_2"  name="RB" /><label for="RB_2" >按照枚举值</label> </legend>
 请选择一个枚举: <select id="DDL_Enums" ></select>
 </fieldset>

 
<fieldset>
<legend><input type="radio" value="3" id="RB_3"  name="RB" /><label for="RB_3" >按照系统外键表计算</label> </legend>
 请选择一个外键表: <select id="DDL_SFTables" ></select>
 </fieldset>

 
<fieldset>
<legend><input type="radio" value="4" id="RB_4"  name="RB" /><label for="RB_4" >按照SQL计算</label> </legend>
<textarea  rows="3" id="Textarea1" name="TB_Docs" ></textarea>
 </fieldset>

<input type="button" value="保存" id="Btn_Save"  onclick="Save()" />
<input type="button" value="删除"  id="Btn_Delete"  onclick="Delete()" />

<a href="javascript:ShowHidden('help')">帮助:</a>
 <div id="help" style="color:Gray; display:none">
 <ul>
 <li>您选择了使用外部的URL. </li>
 <li>使用外部的URL，我们提供了一个demo,您需要按照自己的格式来编写该url.</li>
 <li>该demo的位置 /SDKFlowDemo/SDKFlowDemo/PopSelectVal.htm </li>
 <li>可以使用@SDKFromServHost 变量，标识一个配置路径，该配置在web.config里设置。</li>
 </ul>
 </div>

</form>

</body>
</html>
